import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UnitVO, UnitForm, UnitQuery } from '@/api/system/unit/types';

/**
 * 查询风险分析单元列表
 * @param query
 * @returns {*}
 */

export const listUnit = (query?: UnitQuery): AxiosPromise<UnitVO[]> => {
  return request({
    url: '/system/unit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询风险分析单元详细
 * @param id
 */
export const getUnit = (id: string | number): AxiosPromise<UnitVO> => {
  return request({
    url: '/system/unit/' + id,
    method: 'get'
  });
};

/**
 * 新增风险分析单元
 * @param data
 */
export const addUnit = (data: UnitForm) => {
  return request({
    url: '/system/unit',
    method: 'post',
    data: data
  });
};

/**
 * 修改风险分析单元
 * @param data
 */
export const updateUnit = (data: UnitForm) => {
  return request({
    url: '/system/unit',
    method: 'put',
    data: data
  });
};

/**
 * 删除风险分析单元
 * @param id
 */
export const delUnit = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/unit/' + id,
    method: 'delete'
  });
};
